﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO.Compression;
using System.IO;

namespace D2xstudio.Net
{
    public class Zip
    {
        public static string DeCompress(byte[] content)
        {
            using (MemoryStream mStream = new MemoryStream())
            {
                mStream.Write(content, 0, content.Length);
                mStream.Seek(0, SeekOrigin.Begin);
                using (GZipStream dStream = new GZipStream(mStream, CompressionMode.Decompress))
                {
                    StringBuilder result = new StringBuilder();
                    byte[] buffer = new byte[256];
                    int readedCount = 0;
                    do
                    {
                        readedCount = dStream.Read(buffer, 0, buffer.Length);
                        result.Append(Encoding.ASCII.GetString(buffer, 0, readedCount));
                    }
                    while (readedCount == buffer.Length);
                    return result.ToString();
                }
            }
            
        }
    }
}
